home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / Autoscroller.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  2.4 KB  |  69 lines

  1. package javax.swing;
  2.  
  3. import java.awt.AWTEvent;
  4. import java.awt.Point;
  5. import java.awt.Rectangle;
  6. import java.awt.event.InputEvent;
  7. import java.awt.event.MouseAdapter;
  8. import java.awt.event.MouseEvent;
  9. import java.io.IOException;
  10. import java.io.ObjectInputStream;
  11. import java.io.ObjectOutputStream;
  12. import java.io.Serializable;
  13.  
  14. class Autoscroller extends MouseAdapter implements Serializable {
  15.    transient MouseEvent event;
  16.    transient Timer timer;
  17.    JComponent component;
  18.  
  19.    Autoscroller(JComponent var1) {
  20.       if (var1 == null) {
  21.          throw new IllegalArgumentException("component must be non null");
  22.       } else {
  23.          this.component = var1;
  24.          this.timer = new Timer(100, new AutoScrollTimerAction(this));
  25.          this.component.addMouseListener(this);
  26.       }
  27.    }
  28.  
  29.    void dispose() {
  30.       this.stop();
  31.       this.component.removeMouseListener(this);
  32.    }
  33.  
  34.    public void mouseDragged(MouseEvent var1) {
  35.       Rectangle var2 = this.component.getVisibleRect();
  36.       boolean var3 = var2.contains(var1.getX(), var1.getY());
  37.       if (var3) {
  38.          if (this.timer.isRunning()) {
  39.             this.stop();
  40.          }
  41.       } else {
  42.          Point var4 = this.component.getLocationOnScreen();
  43.          this.event = new MouseEvent(this.component, ((AWTEvent)var1).getID(), ((InputEvent)var1).getWhen(), ((InputEvent)var1).getModifiers(), var1.getX() + var4.x, var1.getY() + var4.y, var1.getClickCount(), var1.isPopupTrigger());
  44.          if (!this.timer.isRunning()) {
  45.             this.timer.start();
  46.          }
  47.       }
  48.  
  49.    }
  50.  
  51.    public void mouseReleased(MouseEvent var1) {
  52.       this.stop();
  53.    }
  54.  
  55.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  56.       var1.defaultReadObject();
  57.       this.timer = new Timer(100, new AutoScrollTimerAction(this));
  58.    }
  59.  
  60.    void stop() {
  61.       this.timer.stop();
  62.       this.event = null;
  63.    }
  64.  
  65.    private void writeObject(ObjectOutputStream var1) throws IOException {
  66.       var1.defaultWriteObject();
  67.    }
  68. }
  69.